
import axios from 'axios'


/*
//axiosonce
const service = axios.create({
    baseURL: 'http://192.100.100.75:9090',
    timeout: 360000, // request timeout
});
*/


function addElemntP(){
    let p=document.createElement("p")
    p.setAttribute('id','request')

    let nodeinner=document.createTextNode("资源请求中...请稍候!")
    p.appendChild(nodeinner);

    let appid=document.getElementById('app');
    let appidfist=appid.firstChild
    appid.insertBefore(p,appidfist)
}

function removElemntP(){
    let isIdRequest=document.getElementById('request');
    if(isIdRequest){
        isIdRequest.parentNode.removeChild(isIdRequest)
    }else {
    }
}



// 添加请求拦截器
axios.interceptors.request.use(function (config) {
    // 在发送请求之前做些什么
    addElemntP()

    return config;
}, function (error) {
    // 对请求错误做些什么
    return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
    // 对响应数据做点什么
    removElemntP();
    return response;
}, function (error) {
    // 对响应错误做点什么
    return Promise.reject(error);
});




//登陆的验证
export const getLogin = (data) => {
    return axios({
        method: 'POST',
        url: '/admin/index/login/',
        data
    })
}









